package android_design_mode.chapter22_flyweight;

import java.util.Random;

public class TrainTicket implements Ticket {

    private String from;
    private String to;
    private String bunk;
    private int price;

    public TrainTicket(String from, String to) {
        this.from = from;
        this.to = to;
    }

    @Override
    public void showTicketInfo(String bunk) {
        price = new Random().nextInt(300);

        System.out.println(String.format("购买从%s到%s的%s火车票，价格：%s", from, to, bunk, price));
    }


}
